<template>
	<view class='search-input' :class='bg'>
		<view class='input'>
			<text class='icon cuIcon-search' ></text>
			<input :value='value' :placeholder="placeholder" @input='handleInput' @confirm='handleSearch'/>
		</view>
		<view class='search-btn' @click='handleSearch'>搜索</view>
		<view class='search-btn' @click='skipSearch' v-if="isSkipBtn">跳过</view>
	</view>
</template>

<script>
	export default {
		props: {
			isSkipBtn:{
				type:Boolean,
				default:false
			},
			bg: {
				type: String, 
				default: 'white' //白色-white 灰色-gray
			},
			placeholder: {
				type: String,
				default: '请输入'
			},
			value: String
		},
		methods: {
			handleInput(e) {
				let val = e.detail.value;
				this.$emit('input', val)
			},
			skipSearch(){
				this.$emit('skipSearch', this.value)
			},
			handleSearch() {
				this.$emit('search', this.value)
			}
		}
	}
</script>

<style scoped lang="scss">
	.search-input {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
		&.white {
			color: #fff;
			
			.input {
				background: #fff;
			}
		
		}
		
		&.gray {
			color: #333333;
			
			.input {
				background: #F6F6F6;
			}
		}
		
	
		
		
		.input {
			flex: 1;
			display: flex;
			border-radius: 29rpx;
			padding-left: 16rpx;
			height: 50rpx;
			align-items: center;
			justify-content: space-between;
			
			
			.icon {
				font-size: 26rpx;
				margin-right: 20rpx;
				color: #333333;
			}
			
			input {
				text-align: left;
				flex: 1;
				font-size: 24rpx;
				color: #999;
			}
		}
		
		.search-btn {
			font-size: 28rpx;
			margin-left: 20rpx;
		}
		
	}
</style>